import { InjectionKey } from 'vue'
import { createStore, useStore as baseUseStore, Store } from 'vuex'
import tag, { TagState } from './modules/tag'
import menu, { MenuState } from './modules/menu'
import loading, { LoadState } from './modules/loading'
import refresh, { RefreshState } from './modules/refresh'
import http, { HttpState } from './modules/http'
import { CommonStore } from './help'
export type RootState = {
  tag: TagState,
  menu: MenuState,
  loading:LoadState,
  refresh:RefreshState,
  http:HttpState
}
//导入所有的模块
export const modules = {
  tag,
  menu,
  loading,
  refresh,
  http
}
export const key: InjectionKey<Store<RootState>> = Symbol()

export const store = createStore<RootState>({
  modules
}) as CommonStore

// 定义自己的 `useStore` 组合式函数
export function useStore() {
  return baseUseStore(key) as CommonStore
}